/*
	Copyright (C) 2009 Salil Bhagurkar
	
	This file is part of ViSE
	
	ViSE is free software: you can redistribute it and/or modify
	it under the terms of the GNU Lesser General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.
	
	ViSE is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU Lesser General Public License for more details.
	
	You should have received a copy of the GNU Lesser General Public License
	along with ViSE.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _EXP_H_
#define _EXP_H_


#include <shared.h>

/*First 6 bits (64 operations) for what to do*/


#define OP_ADD 0
#define OP_SUB 1
#define OP_MUL 2
#define OP_DIV 3

#define OP_MASK 63

/*bit 6,7,8,9 indicate the nature of parameter*/

#define PARAM0_MASK (3 << 6)
#define PARAM1_MASK (3 << 8)

#define INSTR_CONSTANT 0
#define INSTR_SYMBOL 1
#define INSTR_ALLOC 2 //This is the accumulator (temp space to store intermediate result)



struct node_stream {
	u16 flags;
	union {
		u32 op0;
		struct node *node0;
		u32 alloc0; //Temporary space
	};
	union {
		u32 op1;
		struct node *node1;
		u32 alloc1; //Temporary space
	};
};

struct mathvm *parse_expression(const char *exp, u32 nr_clients);


#endif
